class Solution(object):
    def numSteps(self, s):
        if len(s) == 1:
            return 0
        s = list(s)
        s.reverse()
        add = 0
        c = 0
        for i in range(len(s) - 1):
            if int(s[i]) + add == 0:
                c += 1
                add = 0
            else:
                if int(s[i]) + add == 1:
                    c += 2
                    add = 1
                else:
                    c += 1
                    add = 1
        return c + add

